﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Navigation;
using Microsoft.Phone.Controls;
using Microsoft.Phone.Shell;

namespace WP8.PropiedadesEspeciales.UserControls
{
    public partial class ContenedorEspecial : UserControl
    {
        public static int GetEstado(DependencyObject obj)
        {
            return (int)obj.GetValue(EstadoProperty);
        }

        public static void SetEstado(DependencyObject obj, int value)
        {
            obj.SetValue(EstadoProperty, value);
        }

        public static readonly DependencyProperty EstadoProperty =
            DependencyProperty.RegisterAttached("Estado", typeof(int), typeof(ContenedorEspecial), new PropertyMetadata(1, EstadoCallback));

        private static void EstadoCallback(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            var estado = (int)e.NewValue;
            if (estado == 0)
            {
                (d as UIElement).Visibility = Visibility.Collapsed;
            }
            else
            {
                (d as UIElement).Visibility = Visibility.Visible;
            }
        }

        public ContenedorEspecial()
        {
            InitializeComponent();
        }
    }
}
